<div>
  <div class="main-title">
    <h2>{if $id}编辑{else}新增{/if}用户</h2>
  </div>
  <div class="main-section">
    <form method="POST" action="{:url('save')}" class="j-form">
      <ul class="form-group form-inline">
        <li>
          <input type="text" class="form-control" name="username" value="{$data.username}" required>
          <label>用户名</label>
        </li>
        <li>
          <select name="admin_role_id" class="form-control" style="min-width: 196px;">
            <option value="0">未选择</option>
            {foreach $role as $v}
            <option value="{$v.id}" {if $v.id===$data.admin_role_id}selected{/if}>
              {$v.name}
            </option>
            {/foreach}
          </select>
          <label>所属角色</label>
        </li>
        <li>
          <input type="text" class="form-control" name="password" {if $id}placeholder="保持不变" {else}required{/if}>
          <label>密码</label>
        </li>
        <li>
          <input type="hidden" name="id" value="{$id}">
          <input type="submit" value="提交表单" class="btn btn-primary">
          <a href="{:url('index')}" class="btn btn-default">返回列表</a>
        </li>
      </ul>
    </form>
  </div>
</div>

<script>
  main.ajaxForm('.j-form', function() {
    main.content("{:url('index')}");
  });
</script>